package com.huterox.todoscheduler.core.execute.proxy;


import com.huterox.todoscheduler.core.enumType.TodoItemElementType;
import com.huterox.todoscheduler.core.enumType.TodoItemStateType;
import com.huterox.todoscheduler.core.wapper.ItemStateWrapper;
import com.huterox.todoscheduler.handler.*;

import java.io.Serializable;
import java.lang.reflect.Method;

/**
 * 任务清单对应的Item,这里记录的是这个Item基本的信息
 * */
public class TodoItemExBean implements Serializable {

    //任务清单项类型
    public TodoItemElementType todoItemElementType;

    //任务执行顺序
    public int order;

    //这是第几个清单的方法
    private int idx;

    //实例对象
    private Object wrapperInstance;
    //对应的class
    private Class<?> wrapperClass;
    //对应的方法
    private Method wrapperMethod;

    //当前的状态，当然服务宕机恢复任务的时候，这个是一个很重要的凭证
    public TodoItemStateType todoItemStateType;

    TodoItemBeforeCreateHandler todoItemCreateHandler;
    TodoItemAfterRunningHandler todoItemAfterRunningHandler;
    TodoItemBeforeRunningHandler todoItemBeforeRunningHandler;
    TodoItemErrorHandler todoItemErrorHandler;

    private ItemStateWrapper stateWrapper;

    public TodoItemExBean() {
        //初始化的时候就进行创建
        this.stateWrapper = new ItemStateWrapper();
    }

    public TodoItemExBean(int order) {
        this.order = order;
    }

    public ItemStateWrapper getStateWrapper() {
        return stateWrapper;
    }

    public void setStateWrapper(ItemStateWrapper stateWrapper) {
        this.stateWrapper = stateWrapper;
    }


    public Object getWrapperInstance() {
        return wrapperInstance;
    }

    public void setWrapperInstance(Object wrapperInstance) {
        this.wrapperInstance = wrapperInstance;
    }

    public Class<?> getWrapperClass() {
        return wrapperClass;
    }

    public void setWrapperClass(Class<?> wrapperClass) {
        this.wrapperClass = wrapperClass;
    }

    public Method getWrapperMethod() {
        return wrapperMethod;
    }

    public void setWrapperMethod(Method wrapperMethod) {
        this.wrapperMethod = wrapperMethod;
    }

    public TodoItemStateType getTodoItemStateType() {
        return todoItemStateType;
    }

    public void setTodoItemStateType(TodoItemStateType todoItemStateType) {
        this.todoItemStateType = todoItemStateType;
    }

    public int getIdx() {
        return idx;
    }

    public void setIdx(int idx) {
        this.idx = idx;
    }


    @Override
    public String toString() {
        return "the order is "+this.order;
    }

    public TodoItemExBean(TodoItemElementType todoItemElementType, int order, TodoItemBeforeCreateHandler todoItemCreateHandler, TodoItemAfterRunningHandler todoItemAfterRunningHandler, TodoItemBeforeRunningHandler todoItemBeforeRunningHandler, TodoItemErrorHandler todoItemErrorHandler) {
        this.todoItemElementType = todoItemElementType;
        this.order = order;
        this.todoItemCreateHandler = todoItemCreateHandler;
        this.todoItemAfterRunningHandler = todoItemAfterRunningHandler;
        this.todoItemBeforeRunningHandler = todoItemBeforeRunningHandler;
        this.todoItemErrorHandler = todoItemErrorHandler;
    }

    public TodoItemElementType getTodoItemElementType() {
        return todoItemElementType;
    }

    public void setTodoItemElementType(TodoItemElementType todoItemElementType) {
        this.todoItemElementType = todoItemElementType;
    }

    public int getOrder() {
        return order;
    }

    public void setOrder(int order) {
        this.order = order;
    }

    public TodoItemBeforeCreateHandler getTodoItemCreateHandler() {
        return todoItemCreateHandler;
    }

    public void setTodoItemCreateHandler(TodoItemBeforeCreateHandler todoItemCreateHandler) {
        this.todoItemCreateHandler = todoItemCreateHandler;
    }

    public TodoItemAfterRunningHandler getTodoItemAfterRunningHandler() {
        return todoItemAfterRunningHandler;
    }

    public void setTodoItemAfterRunningHandler(TodoItemAfterRunningHandler todoItemAfterRunningHandler) {
        this.todoItemAfterRunningHandler = todoItemAfterRunningHandler;
    }

    public TodoItemBeforeRunningHandler getTodoItemBeforeRunningHandler() {
        return todoItemBeforeRunningHandler;
    }

    public void setTodoItemBeforeRunningHandler(TodoItemBeforeRunningHandler todoItemBeforeRunningHandler) {
        this.todoItemBeforeRunningHandler = todoItemBeforeRunningHandler;
    }

    public TodoItemErrorHandler getTodoItemErrorHandler() {
        return todoItemErrorHandler;
    }

    public void setTodoItemErrorHandler(TodoItemErrorHandler todoItemErrorHandler) {
        this.todoItemErrorHandler = todoItemErrorHandler;
    }

}
